package com.example.demo.LeetCode.arr;

import java.util.ArrayList;
import java.util.List;

/**
 * 二分查找
 */
public class TwoSearch {
    public static int search(int[] nums,int target){
        //[-1,0,3,5,9,12]
      /*  int size = nums.length;
        int left = 0,right = size-1;
        while (left < right){
            int mid = (left + right) /2;
            if (nums[mid] == target){
                return mid;
            }
            //数据在右边
            if (nums[mid] < target){
                left = mid;
            }
            //数据在左边
            else if (nums[mid] > target){
                right = mid;
            }
        }*/

        return -1;
    }

    public static void main(String[] args) {
        int nums[] = {-1,0,3,5,9,12};
        int target = 5;
        System.out.println(search(nums,target));
    }
}
